using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Prototype;

public partial class ViewPayments : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            CalendarFromDate.SelectedDate =new DateTime( DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day);
            CalendarToDate.SelectedDate = CalendarFromDate.SelectedDate;
        }

    }
    protected void ButtonShow_Click(object sender, EventArgs e)
    {
        DateTime fromDate = CalendarFromDate.SelectedDate;
        DateTime toDate = CalendarToDate.SelectedDate;
        Payment[] paymentsIncome = new Payment[] { };
        Payment[] paymentsExpenses = new Payment[] { };
        if (CheckBoxIncome.Checked)
        {
            paymentsIncome = Payment.GetPayments(fromDate, toDate, true);
        }
        if (CheckBoxExpenses.Checked)
        {
            paymentsExpenses = Payment.GetPayments(fromDate, toDate, false);
        }

        List<Payment> allpayments = new List<Payment>(paymentsExpenses);
        allpayments.AddRange(paymentsIncome);
        
        GridViewResult.DataSource = allpayments;
        GridViewResult.DataBind();
    }
}
